<template>
	<view>
		<navigationbar :title="title" />
		<view class="listContainer">
			<view class="cardContainer" v-for="(item, index) in collectionList" :key="index" @click="jobDetail(item)">
				<view class="card">
					<view class="postName">
						<text>{{ item.name }}</text>
						<text>{{ item.salary }}</text>
					</view>
					<view class="companyInfo">
						<text>{{ item.recruitment.company }}</text>
						<text>{{ item.company.financing }}</text>
					</view>
					<view class="hrInfo">
						<image :src="item.recruitment.icon" mode=""></image>
						<text>{{item.recruitment.name}}</text>
						<text>{{item.recruitment.position}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import navigationbar from '../navigationBar.vue';
export default {
	components: {
		navigationbar
	},
	onShow() {
		uniCloud.callFunction({
			name: 'getPostList',
			success: res => {
				let collectionData = res.result.data;
				uniCloud.callFunction({
					name: 'getCollection',
					data: {
						userID: this.$store.state.userID
					},
					success:(res1) => {
						let arr = res1.result.data.collection_list
						this.collectionList = collectionData.filter((item) => {
							return arr.indexOf(item._id) !== -1
						})
					}
				})
			}
		});
	},
	data() {
		return {
			title: '我的收藏',
			collectionList: []
		};
	},
	methods: {
		jobDetail(data) {
			this.$store.commit('setPostData',data)
			uni.navigateTo({
				url: '../postDetail/postDetail',
				animationType: 'pop-in',
				animationDuration: 200
			})
		}
	}
};
</script>

<style lang="scss">
.listContainer {
	overflow: hidden;
	background-color: #f7f7f7;
	.cardContainer {
		background-color: white;
		.card {
			width: 90%;
			margin: 0 auto;
			margin-bottom: 20rpx;
			.postName {
				font-size: 40rpx;
				padding: 25rpx 0 20rpx 0;
				display: flex;
				flex-flow: row;
				justify-content: space-between;
				& > text:last-of-type {
					color: $color;
					margin-right: 20rpx;
					font-size: 35rpx;
				}
			}
			.companyInfo {
				padding-bottom: 20rpx;
				font-size: 25rpx;
				& text:nth-of-type(2) {
					margin-left: 20rpx;
				}
			}
			.hrInfo {
				display: flex;
				flex-flow: row;
				align-items: center;
				font-size: 28rpx;
				padding-bottom: 20rpx;
				image {
					width: 40rpx;
					height: 40rpx;
					border-radius: 20rpx;
				}
				text {
					margin-left: 10rpx;
				}
			}
		}
	}
}
</style>
